<template>
  <div class="film_box">
    <div class="select_box">
      <span class="select_input" @click="showTag = !showTag">
        <i>全部视频</i>
        <i class="iconfont icon-xiala"></i>
      </span>
      <div class="select_keyword" v-show="showTag">
        <div class="tab_title">选择标签</div>
        <div class="tag_box">
          <div
            class="all_tag"
            :class="0 == id ? 'active' : ''"
            @click="selectTag(0)"
          >
            全部视频
          </div>
          <table>
            <tr v-for="(item, index) in tag" :key="index">
              <td
                v-for="item2 in item"
                :key="item2.id"
                @click="selectTag(item2.id)"
                :class="item2.id == id ? 'active' : ''"
              >
                {{ item2.name }}
              </td>
            </tr>
          </table>
        </div>
      </div>
    </div>
    <div class="content_box">
      请求地址失效，无法获取资源
    </div>
  </div>
</template>
<script>
import request from "../../../../api/request"
export default {
  data() {
    return {
      showTag: false,
      tag: [],
      id: 0,
    }
  },
  created() {
    this.getTag()
    // this.getTagVideo()
  },
  methods: {
    async getTag() {
      let res = await request({
        url: "/video/group/list",
        data: {},
        method: "get",
      })
      let num = []
      res.data.forEach((item, index) => {
        if (index > 0 && (index + 1) % 6 == 0) {
          num.push(item)
          this.tag.push(num)
          num = []
        } else {
          num.push(item)
        }
      })
      //   console.log(this.tag)
    },
    selectTag(id) {
      this.id = id
      // this.getTagVideo()
    },
    async getTagVideo() {
      let data = {}
      if (this.id != 0) {
        data = {
          id: this.id,
        }
      }
      console.log(data)
      let res = {}
      try {
        res = await request({
          url: "/video/group",
          data,
          method: "get",
        })
      } catch (e) {
        console.log("wufaqingqiu ")
      }
      console.log(res)
    },
  },
}
</script>
<style lang="scss" scoped>
@import "../../../../../static/scss/common.scss";
@import "./Film.scss";
</style>
